#ifndef __SIGLETON_H__
#define __SIGLETON_H__

#include <memory>

namespace sylar {

namespace {

template<class T, class X, size_t N>
T& GetInstanceX()
{
    static T v;
    return v;
}

template<class T, class X, size_t N>
T& GetInstancePtr()
{
    static std::shared_ptr<T> ptr = std::make_shared<T>();
    return ptr;
}

}


template<class T, class X = void, size_t N = 0>
class Singleton
{
public:
    static T* GetInstance()
    {
        static T v;
        return &v;
    }
};

template<class T,class X = void, size_t N = 0>
class SingletonPtr
{
public:
    static std::shared_ptr<T> GetInstancePtr()
    {
        std::shared_ptr<T> ptr = std::make_shared<T>();
        return ptr;
    }

};


}


#endif